/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package boundary;

import entity.Event;
import entity.User;
import entity.WarningType;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author andrea
 */
@Stateless
public class DataLoader {
    
    @EJB private EventManager eventManger;
    @EJB private UserManager  userManager;
    @EJB private NotificationManager notificationManager;
    
    public List<User> findPublicUser(){
        return userManager.findPublicUser();
    }
    
    public List<Event> findPublicEvent(){
        return eventManger.findPublicEvent();
    }
    
    public Event loadSpecificEvent(Long eventID){
        return eventManger.findSpecificEvent(eventID);
    }
    
    public void joinEvent(Long eventID ){
        Event event = eventManger.loadSpecificevent(eventID);
        eventManger.addPArticiPant(event, userManager.getLoggedUser());
        notificationManager.createWarninForOwner(event, WarningType.NEWPARTICIPANT);
    }
}
